package com.shop.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shop.service.GoodsService;
import com.shop.service.impl.GoodsServiceImpl;

@WebServlet("/selectGoods.do")
public class SelectGoodsServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		GoodsService goodsService = new GoodsServiceImpl();
		int pageNum;
		int pageSize;
		try {
			pageNum = Integer.parseInt(req.getParameter("pageNum"));
		}catch(Exception e) {
			pageNum=1;
		}
		
		try {
			pageSize = Integer.parseInt(req.getParameter("pageSize"));
		}catch(Exception e) {
			pageSize=5;
		}
		req.setAttribute("page", goodsService.selectGoodsAll(pageNum, pageSize));
		req.getRequestDispatcher("goods.jsp").forward(req, resp);

	}
}
